package com.huawei123.hasee.cniao5store.factory;

import com.huawei123.hasee.cniao5store.base.BaseFragment;
import com.huawei123.hasee.cniao5store.mvp.view.fragment.AppManagerFragment;
import com.huawei123.hasee.cniao5store.mvp.view.fragment.CategoryFragment;
import com.huawei123.hasee.cniao5store.mvp.view.fragment.MyFragment;
import com.huawei123.hasee.cniao5store.mvp.view.fragment.RecommendFragment;
import com.huawei123.hasee.cniao5store.mvp.view.fragment.TopFragment;

import java.util.HashMap;
import java.util.Map;

/**
 * 项目名称：Cniao5Store
 * 类描述：
 * 创建人：Administrator
 * 创建时间：2017/10/25 0025 下午 4:29
 * 修改人：Administrator
 * 修改时间：2017/10/25 0025 下午 4:29
 * 修改备注：
 */

public class FragmentFactory {
    /*推荐*/
    public static final int TAB_RECOMMEND = 0;
    /*分类*/
    public static final int TAB_CATEGORY = 1;
    /*排行*/
    public static final int TAB_TOP = 2;
    /*管理*/
    public static final int TAB_APPMANAGER = 3;
    /*我的*/
    public static final int TAB_MY = 4;

    private static Map<Integer, BaseFragment> bindFragment = new HashMap<>();

    public static BaseFragment createFragment(int position) {
        BaseFragment fragment = bindFragment.get(position);
        if (fragment == null) {
            switch (position) {
                case TAB_RECOMMEND:
                    fragment = new RecommendFragment();
                    break;
                case TAB_CATEGORY:
                    fragment = new CategoryFragment();
                    break;
                case TAB_TOP:
                    fragment = new TopFragment();
                    break;
                case TAB_APPMANAGER:
                    fragment = new AppManagerFragment();
                    break;
                case TAB_MY:
                    fragment = new MyFragment();
                    break;
            }
            bindFragment.put(position, fragment);
        }
        return fragment;
    }
}
